(function(){
	var WKH_focusFix = {
		skipClass : 'skip',
		
		init : function(){
			var 
				userAgent = navigator.userAgent.toLowerCase(),
				is_webkit = userAgent.indexOf('webkit') > -1,
				is_ie = userAgent.indexOf('msie') > -1;
				
			if(is_webkit || is_ie){
				var 
					body = document.body,
					handler = WKH_focusFix.click;
					
				if(body.addEventListener){
					body.addEventListener('click', handler, false);
				}else if(body.attachEvent){
					body.attachEvent('onclick', handler);
				}
			}
		},
		
		click : function(e){
			e = e || window.event;
			var target = e.target || e.srcElement;
			if(target.className.indexOf(WKH_focusFix.skipClass) > -1){
				WKH_focusFix.focus(target);
			}
		},
		
		focus : function(link){
			var 
				href = link.href,
				id = href.substr(href.indexOf('#') + 1),
				target = document.getElementById(id);
			
			if(target){
				target.setAttribute('tabindex', '-1');
				target.focus();
			}
		}
	};
	WKH_focusFix.init();
})();